# This is a sample Python script.

# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.


def print_hi(name):
    # Use a breakpoint in the code line below to debug your script.
    print(f'Hi, {name}')  # Press Ctrl+F8 to toggle the breakpoint.


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    print_hi('PyCharm')

# See PyCharm help at https://www.jetbrains.com/help/pycharm/

import numpy as np
import random as rd
title=[['python','math','chinese']]

#a1,a2,a3,a4,a5,a6 六个班的三门课程的考试成绩
a1=np.random.randint(0,100,size=(50,3),dtype='int')
a2=np.random.randint(0,100,size=(50,3),dtype='int')
a3=np.random.randint(0,100,size=(50,3),dtype='int')
a4=np.random.randint(0,100,size=(50,3),dtype='int')
a5=np.random.randint(0,100,size=(50,3),dtype='int')
a6=np.random.randint(0,100,size=(50,3),dtype='int')
#c=np.random.uniform(0,100,size=(5,3))
#d=np.asarray(c,dtype='float16')
#成绩合并变成score
score=np.concatenate([a1,a2,a3,a4,a5,a6])
sex=np.random.randint(0,2,size=(300,1))
data=np.concatenate([score,sex],axis=1)
#print(data[:,3])
#用where条件找出性别为男(第四列为1)的数据索引
boys=np.where(data[:,3]==1)
girls=np.where(data[:,3]==0)
boy_avg=(data[boys].mean(axis=0))
girl_avg=(data[girls].mean(axis=0))
boy_max=(data[boys].max(axis=0))
girl_max=(data[girls].max(axis=0))
boy_min=(data[boys].min(axis=0))
girl_min=(data[girls].min(axis=0))
boy_std=(data[boys].std(axis=0))
girl_std=(data[girls].std(axis=0))
boy_median=np.median(data[boys],axis=0)
girls_median=np.median(data[girls],axis=0)
print('\t男生各科成绩情况:\n')
print('\tPython\t','数学\t','语文\n')
for i in range(0, 3):
    if i==0:
        print('最小值:',end='')
    print('\t', boy_min[i], end='\t')
print()
for i in range(0, 3):
    if i==0:
        print('最大值:',end='')
    print('\t', boy_max[i], end='\t')
print()
for i in range(0, 3):
    if i==0:
        print('平均值:',end='')
    print('\t%.2f'%boy_avg[i], end='')
print()
for i in range(0, 3):
    if i==0:
        print('中位数:',end='')
    print('\t', boy_median[i], end='')
print()
for i in range(0, 3):
    if i==0:
        print('标准差:',end='')
    print('\t%.2f'%boy_std[i], end='')
print()
#女生成绩情况
print('\t女生各科成绩情况:\n')
print('\tPython\t','数学\t','语文\n')
for i in range(0, 3):
    if i==0:
        print('最小值:',end='')
    print('\t', girl_min[i], end='\t')
print()
for i in range(0, 3):
    if i==0:
        print('最大值:',end='')
    print('\t', girl_max[i], end='\t')
print()
for i in range(0, 3):
    if i==0:
        print('平均值:',end='')
    print('\t%.2f'%girl_avg[i], end='')
print()
for i in range(0, 3):
    if i==0:
        print('中位数:',end='')
    print('\t', girls_median[i], end='')
print()
for i in range(0, 3):
    if i==0:
        print('标准差:',end='')
    print('\t%.2f'%girl_std[i], end='')
